using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace NhanVien
{
    class Database
    {
        private SqlConnection sqlConn;
        public Database()
        {
            string svrName, dbName, uid, pwd;
            bool integratedMode;
            svrName = "hawk";
            dbName = "LibraryManagement";
            integratedMode = true;
            uid = "";
            pwd = "";
            string connStr;
            if (integratedMode == true)
            {
                connStr = String.Format("server={0}; database={1}; Integrated Security = True", svrName, dbName);
            }
            else
            {
                connStr = String.Format("server={0}; uid={1}; pwd={2} ;database={3}", svrName, uid, pwd, dbName);
            }
            sqlConn = new SqlConnection(connStr);
        }
        public DataTable Execute(string strQuery)
        {
            SqlDataAdapter da = new SqlDataAdapter(strQuery, sqlConn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
        public void ExecuteNonQuery(string strQuery)
        {
            using (SqlCommand sqlCom = new SqlCommand(strQuery, sqlConn))
            {
                sqlConn.Open();
                
                sqlCom.ExecuteNonQuery();
            }
            sqlConn.Close();
        }
	
    }
}
